home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / keyboard.swg / 0006_Turn Keyboard OFF.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-28  |  1.8 KB  |  63 lines

  1. {IDIOT PASCAL 101
  2. ----------------
  3.  
  4. Welcome to IP 101. In today's lesson we will be answering a few
  5. often asked questions about Turbo Pascal. if you signed up For
  6. IDIOT C/C++ 101, please get up and run beFore you get shot.
  7.  
  8. Q:  HOW do I TURN ofF/ON THE KEYBOARD FROM MY Program?
  9. A:  Easy. Though you may search through many books, you will find
  10.     the answer in a Excellent reference called _THE MS-Dos
  11.     ENCYCLOPEDIA_. It tells of a mystical I/O port where you can
  12.     turn off/on the keyboard by just flipping a bit. This port is
  13.     the 8259 Programmible Interrupt Controller. Now, part of the
  14.     8259 is the Interrupt Mask Register, or IMR For short. The
  15.     port location is $21. to turn off the Keyboard...(RECKLESSLY)
  16.  
  17. }    Procedure KEYBOARD_ofF;
  18.  
  19.       begin
  20.         PorT[$21]:=$02
  21.       end;
  22. {
  23.     to turn the keyboard back on (RECKLESSLY), just set the port
  24.     back to $0.
  25.  
  26.       (THE MSDos ENCYCLOPEDIA (C) 1988 Microsoft Press p417)
  27.  
  28. Q: HOW do I FLIP BITS ON/ofF in A Byte or Integer?
  29. A: Simple, Really.  The following Procedures work on both
  30.    Byte,Char,Boolean,Integer, and Word values(I hope).
  31. }
  32. Procedure SBIT(Var TARGET;BITNUM:Integer);   {set bit}
  33.  
  34. Var
  35.   SUBJECT : Integer Absolute TARGET;
  36.   MASK    : Integer;
  37.  
  38.  begin
  39.    MASK := 1 SHL BITNUM;
  40.    SUBJECT := SUBJECT or MASK
  41.  end;
  42.  
  43. Procedure CBIT(Var TARGET;BITNUM:Integer);  {clear bit}
  44.  
  45.  Var
  46.    SUBJECT : Integer Absolute TARGET;
  47.    MASK    : Integer;
  48.  
  49.   begin
  50.     MASK := not(1 SHL BITNUM);
  51.     SUBJECT := SUBJECT and MASK
  52.   end;
  53.  
  54. Procedure SETBIT(Var TARGET;BITNUM:Integer;VALUE:Byte);{control}
  55.                                                        {Proc.  }
  56.  begin
  57.    if VALUE = 1 then
  58.      SBIT(TARGET,BITNUM)
  59.    else
  60.      CBIT(TARGET,BITNUM)
  61.  end;
  62.  
  63.